package com.harmony.pilot.knowledge.entity;

import lombok.Data;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * Bundle.json实体
 * 记录OpenHarmony组件的bundle.json配置信息
 */
@Data
@Entity
@Table(name = "bundle_json", indexes = {
    @Index(name = "idx_bundle_path", columnList = "file_path"),
    @Index(name = "idx_bundle_name", columnList = "name"),
    @Index(name = "idx_bundle_subsystem", columnList = "subsystem")
})
public class BundleJson {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /** 文件路径 */
    @Column(name = "file_path", nullable = false, length = 1000, unique = true)
    private String filePath;
    
    /** 组件名称 */
    @Column(name = "name", nullable = false, length = 500)
    private String name;
    
    /** 描述 */
    @Column(name = "description", columnDefinition = "TEXT")
    private String description;
    
    /** 版本 */
    @Column(name = "version", length = 50)
    private String version;
    
    /** 许可证 */
    @Column(name = "license", length = 100)
    private String license;
    
    /** 子系统 */
    @Column(name = "subsystem", length = 255)
    private String subsystem;
    
    /** 组件名称（component.name） */
    @Column(name = "component_name", length = 255)
    private String componentName;
    
    /** 系统能力列表（JSON数组） */
    @Column(name = "syscap", columnDefinition = "TEXT")
    private String syscap;
    
    /** 特性列表（JSON数组） */
    @Column(name = "features", columnDefinition = "TEXT")
    private String features;
    
    /** 依赖关系（JSON对象） */
    @Column(name = "deps", columnDefinition = "TEXT")
    private String deps;
    
    /** 完整JSON内容 */
    @Column(name = "content", columnDefinition = "TEXT")
    private String content;
    
    /** ROM大小 */
    @Column(name = "rom", length = 50)
    private String rom;
    
    /** RAM大小 */
    @Column(name = "ram", length = 50)
    private String ram;
    
    /** 适配的系统类型（JSON数组） */
    @Column(name = "adapted_system_type", columnDefinition = "TEXT")
    private String adaptedSystemType;
    
    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;
    
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;
    
    @PrePersist
    protected void onCreate() {
        createdAt = LocalDateTime.now();
        updatedAt = LocalDateTime.now();
    }
    
    @PreUpdate
    protected void onUpdate() {
        updatedAt = LocalDateTime.now();
    }
}

